home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* */
- /* */
- /* ------------ Bit-Bucket Software <no-Inc> */
- /* \ 10001101 / Writers and Distributors of */
- /* \ 011110 / No-Cost<no-tm> Software. */
- /* \ 1011 / */
- /* ------ */
- /* */
- /* Copyright (C) 1987, 1988, 1989 by Robert Hartman and Vincent Perriello */
- /* */
- /* */
- /* MODEM7 file name transfer */
- /* */
- /* */
- /* For complete details of the licensing restrictions, please refer */
- /* to the License agreement, which is published in its entirety in */
- /* the MAKEFILE and BT.C, and also contained in the file LICENSE.210. */
- /* */
- /* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
- /* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
- /* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
- /* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT THE AUTHORS */
- /* AT THE ADDRESSES LISTED BELOW. IN NO EVENT SHOULD YOU PROCEED TO */
- /* USE THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE */
- /* BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU */
- /* ARE ABLE TO REACH WITH THE AUTHORS. */
- /* */
- /* */
- /* The Authors can be reached at the following addresses: */
- /* */
- /* Robert C. Hartman Vincent E. Perriello */
- /* Spark Software VEP Software */
- /* 427-3 Amherst Street 111 Carroll Street */
- /* CS2032, Suite 232 Naugatuck, CT 06770 */
- /* Nashua, NH 03061 */
- /* */
- /* FidoNet 1:132/101 FidoNet 1:141/491 */
- /* Data (603) 888-8179 Data (203) 729-7569 */
- /* */
- /* Please feel free to contact us at any time to share your comments */
- /* about our software and/or licensing policies. */
- /* */
- /* */
- /* This module is based largely on a similar module in OPUS-CBCS V1.03b. */
- /* The original work is (C) Copyright 1987, Wynn Wagner III. The original */
- /* author has graciously allowed us to use his code in this work. */
- /* */
- /*--------------------------------------------------------------------------*/
-
- #include <ctype.h>
- #include <conio.h>
-
- #ifdef __TURBOC__
- #include <mem.h>
- #else
- #include <memory.h>
- #endif
-
- #include "com.h"
- #include "xfer.h"
- #include "zmodem.h"
- #include "keybd.h"
- #include "sbuf.h"
- #include "sched.h"
- #include "externs.h"
- #include "prototyp.h"
- #include "find.h" /*PLF Fri 05-05-1989 23:03:42 */
-
-
- /*--------------------------------------------------------------------------*/
- /* XFERMDM7 */
- /*--------------------------------------------------------------------------*/
- int xfermdm7 (fn)
- char *fn;
- {
- unsigned char checksum;
- int i, j;
- unsigned char mdm7_head[13];
- unsigned char num_tries = '\0';
- char *fname;
- FSCAN *dhand; /*PLF Fri 05-05-1989 22:56:40 */
-
- XON_DISABLE ();
- dhand = opendir(); /*PLF Fri 05-05-1989 23:02:49 */
- findfirst(fn, _A_NORMAL, dhand); /*PLF Fri 05-05-1989 23:02:50 */
- fname = dhand->name; /*PLF Fri 05-05-1989 23:02:52 */
-
- /*--------------------------------------------------------------------*/
- /* Build a Modem7 style head */
- /*--------------------------------------------------------------------*/
- memset (mdm7_head, ' ', 12);
- for (i = j = 0; ((fname[i]) && (i < 12) && (j < 12)); i++)
- {
- if (fname[i] == '.')
- j = 8;
- else mdm7_head[j++] = (char) toupper (fname[i]);
- }
- closedir(dhand); /*PLF Fri 05-05-1989 23:02:42 */
- checksum = SUB;
- for (i = 0; i < 11; i++)
- checksum += mdm7_head[i];
-
- /*--------------------------------------------------------------------*/
- /* Top of the Name-Transfer Loop */
- /*--------------------------------------------------------------------*/
- top:
- if (!CARRIER)
- return 0;
- else if (num_tries++ > 10)
- {
- message (_s_mdm7giveup);
- send_can ();
- return (0);
- }
- else if (num_tries)
- SENDBYTE ('u');
-
- /*--------------------------------------------------------------------*/
- /* Wait for a Nak */
- /*--------------------------------------------------------------------*/
- for (i = 0; i < 15; i++)
- {
- if (!CARRIER)
- return (0);
- j = TIMED_READ (4);
- switch (j)
- {
- case 'C':
- SENDBYTE (SOH);
- return 2;
- case NAK:
- i = 16;
- break;
- case CAN:
- return 0;
- }
- }
-
- /*--------------------------------------------------------------------*/
- /* Transmit the file name */
- /*--------------------------------------------------------------------*/
- SENDBYTE (ACK);
- for (i = 0; i < 11; i++)
- {
- SENDBYTE (mdm7_head[i]);
- switch (j = TIMED_READ (10))
- {
- case ACK:
- break;
- case CAN:
- SENDBYTE (ACK);
- return (0);
- default: /* cprintf(_s_mdm7idunno,j); */
- goto top;
- } /* switch */
- }
-
- /*--------------------------------------------------------------------*/
- /* Transmit SUB and get CheckSum */
- /*--------------------------------------------------------------------*/
- SENDBYTE (SUB);
- if ((i = TIMED_READ (10)) != checksum)
- {
- message (_s_mdm7chksum);
- goto top;
- }
-
- SENDBYTE (ACK);
- return (1);
- }
-
- /* END OF FILE: xfermdm7.c */